<!DOCTYPE HTML>
<html style="background: #f3f3f3;">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>法援宝</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/lawyer.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/lawyer.js"></script>
</head>
<body>
<div id="secHeader">
  <header class="header">
      <a href="javascript:void(0);" onclick="api.closeWin()" class="back_btn"><img src="../image/head-fanhui.png" alt=""></a>
      <h2>绑定银行卡</h2>
      <!--<a href="javascript:;" class="tel_btn">保存</a>-->
  </header>
</div>
<section class="binding_bankCard">
    <ul>
        <li>
            <div class="info_item">
                <p>姓名</p>
                <input type="text" placeholder="请输入姓名" id='name'>
            </div>
        </li>
         <li>
            <div class="info_item">
                <p>手机号</p>
                <input type="text" placeholder="请输入银行预留手机号" id='phone'>
            </div>
        </li>
        <li>
            <div class="info_item">
                <p>卡号</p>
                <input type="text" placeholder="请输入开户行" id='bank'>
            </div>
        </li>
        <li>
            <div class="info_item">
                <p>卡号</p>
                <input type="text" placeholder="请输入卡号" id='cardno'>
            </div>
        </li>


        <li>
            <div class="info_item">
                <p>身份证号</p>
                <input type="text" placeholder="请输入身份证号" id='icno'>
            </div>
        </li>
        <li>
            <div class="info_item">
                <p>手机验证码</p>
                <div class="send_code">
                    <input type="text" placeholder="请输入验证码" id='yzm'>
                    <a href="javascript:void (0);" class="send_btn" id="regyzm">发送验证码</a>
                </div>
            </div>
        </li>
    </ul>
</section>
<section class="calc_btn">
    <a href="javascript:void (0);" onclick='tijiao()'>绑定银行卡</a>
</section>



</body>

<script>
    apiready = function () {
      $api.fixStatusBar( $api.dom('#secHeader') );
      api.setStatusBarStyle({
          style: 'light'
      });
        

        user()
    };
    function user() {
        var p={token:token};
        api.ajax({
            url: webSiteUrl+'/app/user/user',
            method: 'post',
            data: {
                values:p
            }
        }, function(ret, err) {
            if(ret.code==200){
                if(ret.data.bank!=''){
                    $('#bank').val(ret.data.bank)
                }
                if(ret.data.cardno!=''){
                    $('#cardno').val(ret.data.cardno)
                }
                $('#name').val(ret.data.nickname)
                $('#phone').val(ret.data.phone)
                $('#icno').val(ret.data.icno)

            }
        });

    }

    $('#regyzm').click(function () {
        if($(this).hasClass('regyzm')==false){
            var phone=$('#phone').val();
            if(phone==''){
                alert("请输入手机号！");return;
            }else if(!/^1[345678]\d{9}$/.test(phone)){
                alert("手机号格式错误！");return;
            }

            var p={phone:phone,type:2};
            api.ajax({
                url: webSiteUrl+'/app/public/yzm',
                method: 'post',
                data: {
                    values:p
                }
            }, function(ret, err) {
                if(ret.code==200){

                    $('#regyzm').addClass('regyzm');
                    var num=60;
                    timer=setInterval(function(){
                        $('#regyzm').html(num+'秒');
                        num--;
                        if(num==0){
                            clearInterval(timer);
                            timer=null;
                            $('#regyzm').html('重新获取');
                            $('#regyzm').removeClass('regyzm');
                        }
                    },1000)

                    alert(ret.msg)

                }else{alert(ret.msg)}
            });

        }
    })

    function tijiao(){
        var name=$('#name').val();
        var phone=$('#phone').val();
        var yzm=$('#yzm').val();
        var cardno=$('#cardno').val();
        var bank=$('#bank').val();
        var icno=$('#icno').val();
        if(name==''){
            alert("请输入姓名！");return;
        }
        if(phone==''){
            alert("请输入手机号！");return;
        }else if(!/^1[345678]\d{9}$/.test(phone)){
            alert("手机号格式错误！");return;
        }
        if(yzm==''){
            alert("请输入验证码！");return;
        }
        if(cardno==''){
            alert("请输入银行卡号！");return;
        }
        if(bank==''){
            alert("请输入开户行！");return;
        }
        if(icno==''){
            alert("请输入身份证号！");return;
        }


        var  p={token:token,phone:phone,cardno:cardno,bank:bank,yzm:yzm};
        api.ajax({
            url: webSiteUrl+'/app/user/bankcard',
            method: 'post',
            data: {
                values:p
            }
        }, function(ret, err) {
            if(ret.code==200){

                alert(ret.msg);
                api.openWin({
                    name: 'personal_info',
                    url: './personal_info.html',
                    reload:true,
                    pageParam: {

                    }
                });

            }else{
                alert(ret.msg)
            }

        });
    }






</script>
</html>
